﻿<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
      Id="{B18D5C30-107A-44d9-B106-16D259DE8036}"
      GroupId="GeneralSettings"
      Location="Microsoft.SharePoint.ListEdit"
      RequireSiteAdministrator="FALSE"
      Sequence="100"
      Title="Show/hide fields (SPC3)">
    <UrlAction Url="_layouts/Com.CodePlex.SPC3/ShowHideFields.aspx?List={ListId}" />
  </CustomAction>
  <CustomAction
      Id="{CC1A996C-A50C-430f-8666-70747F7C8D9D}"
      Location="CommandUI.Ribbon"
      RegistrationType="ContentType"
      Rights="ManageLists"
      RegistrationId="0x01">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <!-- ContextualGroup needs to be activate by code -->
        <!--
        <CommandUIDefinition Location="Ribbon.ContextualTabs._children">
          <ContextualGroup 
              Id="Ribbon.GlobalCustom"
              Sequence="500" 
              Color="Orange" 
              Title="Custom">
              -->
        <!-- add Tab to Ribbon.LibraryContextualGroup._children -->
        <!-- add Button to Ribbon.Library.Settings.Controls._children -->
        <CommandUIDefinition Location="Ribbon.Tabs._children">
            <Tab
                Id="Ribbon.Extended"
                Title="Extended"
                Description="Extended Settings"
                Sequence="600">
              <Scaling
                  Id="Ribbon.Extended.Scaling">
                <MaxSize
                    Id="Ribbon.Extended.Scaling.SPC3.MaxSize"
                    Sequence="10"
                    GroupId="Ribbon.Extended.SPC3"
                    Size="Large" />
                <Scale
                    Id="Ribbon.Extended.Scaling.SPC3.Scale"
                    Sequence="20"
                    GroupId="Ribbon.Extended.SPC3"
                    Size="Large" />
              </Scaling>
              <Groups Id="Ribbon.Extended.Groups">
                <Group
                   Id="Ribbon.Extended.SPC3"
                   Sequence="10"
                   Description="SPC3 Settings"
                   Title="SPC3"
                   Template="Ribbon.Templates.ExtendedLarge">
                  <Controls Id="Ribbon.Extended.SPC3.Controls">
                    <Button
                      Id="Ribbon.Extended.SPC3.ShowHideFields"
                      Sequence="10"
                      Command="Ribbon.Extended.SPC3.ShowHideFields"
                      Image16by16="/_layouts/images/ctom16.png"
                      Image32by32="/_layouts/images/ctom32.png"
                      LabelText="Show/Hide Fields"
                      ToolTipTitle="Show/Hide Fields"
                      ToolTipDescription="Opens the Show In configuration page where you can set fields to be shown or hidden in list forms"
                      TemplateAlias="button1"
                      Alt="Show In" />
                  </Controls>
                </Group>
              </Groups>
            </Tab>
          <!--</ContextualGroup>-->
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Templates._children">
          <GroupTemplate Id="Ribbon.Templates.ExtendedLarge">
            <Layout Title="Large" LayoutTitle="Large">
              <OverflowSection Type="OneRow" TemplateAlias="button1" DisplayMode="Large"/>
              <!--
              <Section Alignment="Top" Type="OneRow">
                <Row>
                  <ControlRef DisplayMode="Large" TemplateAlias="button1" />
                </Row>
              </Section>
              -->
            </Layout>
          </GroupTemplate>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="Ribbon.Extended.SPC3.ShowHideFields"
          CommandAction="~site/_layouts/Com.CodePlex.SPC3/ShowHideFields.aspx?List={ListId}"
          />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
  <!--
  <CustomAction 
    Id="Com.CodePlex.SPC3.ShowHideFields.ListRibbon.Script"
    Location="ScriptLink"
    ScriptBlock="           
      function redirect(url) {
        var context = new SP.ClientContext.get_current();  
        var site = context.get_site();
        context.load(site, 'Url', 'ServerRelativeUrl');  
        context.executeQueryAsync(function(sender, args) {
          alert('site url:' + site.get_url() + '\n rel url:' + site.get_serverRelativeUrl());  
          var customPage = site.get_serverRelativeUrl() + '/_layouts/custompage.aspx';
          window.location= customPage;
          //TODO - pass through item id if one is selected
        }, function(sender, args) {
          alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());  
        });  
      } 
    " />
    -->
</Elements>
